import cv2
import numpy as np

from test_template import find_all_matches, draw_matches
from test_brightness import split_by_brightness


threshold = 155  # 设置亮度阈值

image_bright = split_by_brightness(
    'demo_new.png',
    threshold,
    value=0,
    dvalue=20
)

template_bright = split_by_brightness(
    'imgs/baicai.png',
    threshold,
)


image = np.array(image_bright)
template = np.array(template_bright)

# 找到所有匹配的元素
matches = find_all_matches(image, template, threshold=0.5)

# 绘制匹配区域
matched_image = draw_matches(image, matches)
matched_image_gray = cv2.cvtColor(matched_image, cv2.COLOR_BGR2GRAY)
# 显示结果
cv2.imshow('Matched Areas', matched_image_gray)
cv2.waitKey(0)
cv2.destroyAllWindows()

